﻿using System.Collections.Generic;
using System.Linq;

namespace Inscriptionem.Areas.Inscriptionem.Models.Views
{
    public class PageSearchCollectionViewModel
    {
        public IEnumerable<ORM.Page> Pages { get; protected set; }

        public PageSearchCollectionViewModel()
        {
            Pages = new ORM.DB().Pages.Where(p => p.Title.ToLower().Contains(Text.ToLower()) || p.Content.ToLower().Contains(Text.ToLower()))
                .OrderBy(p => p.Section.Language.ID).ThenBy(p => p.Section.ID).ThenBy(p => p.ID);
        }

        public string Text { get; set; }
        public int Page { get; set; }
    }
}